package io.renren.modules.example;
import io.renren.common.utils.R;
import io.renren.modules.sys.controller.AbstractController;
import io.renren.modules.sys.entity.SysUserEntity;
import io.swagger.annotations.*;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*;
//我修改了develop的代码
@RestController
@RequestMapping("hello")
@Api(tags = "这是一组测试示例接口")
public class HelloController extends AbstractController {
    @GetMapping("demo01/get")
    @ApiOperation("get无参测试")
    @ApiResponse(code = 0,message = "请求成功")
    @ApiImplicitParam(value = "鉴权token",name = "token",paramType = "header", dataType = "String", required=true)
    @RequiresPermissions("demo01:get")
    public R demo01(){
        SysUserEntity user = getUser();
        System.out.println("当前访问接口的用户信息是："+ user);
        System.out.println("userId是："+getUserId());
        return R.ok("demo01-get::develop合并到master:2020-7-29");

    }

    @GetMapping("demo02/get")
    @ApiOperation("get有参测试")
    @ApiImplicitParam(value = "鉴权token",name = "token",paramType = "header", dataType = "String", required=true)
    @RequiresPermissions("demo02:get")
    public R demo02(
            @RequestParam
            @ApiParam("产品编号")
            Long productId,
            @RequestParam
            @ApiParam("产品名称")
            String productName){
        return R.ok("productId:"+productId+",productName:"+productName);
    }
    @GetMapping("demo03/get/{productId}")
    @ApiOperation("get无参带路径变量测试")
    @ApiImplicitParam(value = "鉴权token",name = "token",paramType = "header", dataType = "String", required=true)
    @RequiresPermissions("demo03:get")
    public R demo03(
            @PathVariable("productId")
            @ApiParam("产品编号")
            Long productId){
        return R.ok("productId:"+productId);
    }
    @PostMapping("demo04/post")
    @ApiOperation("post有参带路径变量测试")
    @ApiImplicitParam(value = "鉴权token",name = "token",paramType = "header", dataType = "String", required=true)
    @RequiresPermissions("demo04:get")
    public R demo04(@RequestBody TestVo testVo){
        return R.ok("接收到的实体类是："+ testVo.toString());
    }
}
